package com.wyj.rpc.controller;

import com.alibaba.fastjson.JSONObject;
import com.wyj.rpc.config.RpcClient;
import com.wyj.rpc.config.RpcServiceProxy;
import com.wyj.rpc.pojo.User;
import com.wyj.rpc.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

/**
 * TODO:
 *
 * @author wuyijie
 * @date 2021/12/26 2:18 下午
 */
@RestController
@RequestMapping("/user")
public class UserController {
    IUserService userService;

    @PostConstruct
    public void init() {
        userService = (IUserService) RpcServiceProxy.createProxy(IUserService.class);
    }

    @GetMapping("/{id}")
    public User user(@PathVariable Integer id) {
        return userService.findById(id);
    }

}
